/**
 * 
 */

jQuery(function(){
	var mm_talker = mm_talker || {};
	mm_talker.settingid = 'kf_10300_1324372450463';
	mm_talker.setting = mm_talker.setting || {};
	//ntalker聊窗通知选鞋顾问按钮聊窗状态变化
	//status: 1：聊窗打开；2：聊窗最小化；3：聊窗关闭
	window.ntcall_onChatWindowStatus = function (status)
	{
		var host = document.domain;
		var status_html = '<img src="http://www.masamaso.com/templates/images/ntalker_status_'+status+'.jpg" />';
		
		switch(status)
		{
			case 1:
				if(/linkmasa/.test(host))
				{
					jQuery('#line_service_ntalke').html('咨<br>询<br>中<br>...');
				}else
				{
					jQuery('#line_service_ntalke').html(status_html);
				}
				break;
			case 2:
				if(/linkmasa/.test(host))
				{
					jQuery('#line_service_ntalke').html('咨<br>询<br>中<br>...');
				}else
				{
					jQuery('#line_service_ntalke').html(status_html);
				}
				break;
			case 3:
				if(/linkmasa/.test(host))
				{
					jQuery('#line_service_ntalke').html('在<br>线<br>客<br>服');
				}else
				{
					jQuery('#line_service_ntalke').html(status_html);
				}
				break;
			default:
				break;
		}
	}
	
	window.ntcall_openInPageChat = function(item_id)
	{
		
		if( typeof NTKF.im_openInPageChat != "undefined" ){
            NTKF = typeof NTKF != "undefined" ? NTKF : {}; 

            NTKF.customParentID = 'infodiv';
            NTKF.im_openInPageChat(mm_talker.settingid, item_id);
            window.ntcall_onChatWindowStatus(1);
        }
	}
	
	var product_code = '0';
	
	//MASA VIVIAN获得商品款号的方式
	if(jQuery('input#product_id').length >0)
	{
		product_code = jQuery('input#product_id').val();
	}
	//linkmasa套装获得款号的方式
	if(jQuery('input#suit_code').length >0)
	{
		product_code = jQuery('input#suit_code').val()
	}
	//linkmasa单品获得款号的方式
	if(jQuery('input#productID').length >0)
	{
		product_code = jQuery('input#productID').val()
	}
	
	if(product_code == '' || product_code == null)
	{
		product_code = 0;
	}
	
	if(/\.masa/.test(document.domain))
	{
		if(product_code == 0)
		{
			product_code ='';
		}else
		{
			product_code +='-1-1';
		}
	}
	
	if(/vivian/.test(document.domain))
	{
		if(product_code == 0)
		{
			product_code ='';
		}else
		{
			product_code +='-2-1';
		}
	}
	
	if(/linkmasa/.test(document.domain))
	{
		if(product_code == 0)
		{
			product_code ='';
		}else
		{
			if(jQuery('input#suit_code').length >0)
			{
				product_code +='-3-2';
			}else
			{
				product_code +='-3-1';
			}
		}
	}
	
	window._NTKF_PID = product_code;
	
	
	
	var ntalker_html = ''
	
	var str = '';
	
      str='<script type="text/javascript" src="http://static.masamaso.com/js/ntalker2.js"><\/script>'
	 jQuery('body').append(str);
	//防止外部JS未加载成功  页面元素就显示出来
	var T = window.setInterval(function(){
		if(typeof NTKF == "object")
		{
			if(/linkmasa/.test(document.domain))
			{
				ntalker_html 	+= '<a id="line_service_ntalke" href="javascript:ntcall_openInPageChat(\''+product_code+'\');" class="service_online">在<br \/>线<br \/>客<br \/>服<\/a>'
								+ '<!--[if IE 6]>'
								+ '<style type="text/css">'
								+ 'body {background-image:url(about:blank);background-attachment:fixed;/*必要，防抖动*/}'
								+ '.service_online {position:absolute;top:expression(eval(document.documentElement.scrollTop)+document.documentElement.clientHeight-100);}'
								+ '</style>'
								+ '<![endif]-->';
			}else
			{
				ntalker_html += 	'<style type="text/css">'
				+'.alone_online {display:block;position:fixed;right:0;bottom:0;width:31px;height:115px;z-index:9999}'
				+'</style>'
				+'<a href="javascript:ntcall_openInPageChat(\''+product_code+'\');" id="line_service_ntalke" class="alone_online">'
				+'<img src="http://www.masamaso.com/templates/images/ntalker_status_3.jpg" />'
				+'</a>'
				+'<!--[if IE 6]>'
				+'<style type="text/css">'
				+'body {background-image:url(about:blank);background-attachment:fixed;/*必要，防抖动*/}'
				+'.alone_online {position:absolute;top:expression(eval(document.documentElement.scrollTop)+document.documentElement.clientHeight-115);}'
				+'</style>'
				+'<![endif]-->';
			}
			jQuery('body').append(ntalker_html);
			window.clearInterval(T);
		}
	},30,product_code,ntalker_html,T);
	

})



